package com.global.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.compass.annotations.Searchable;

/**
 * 定义操作人、操作时间
 * @author zly601436
 *
 */
@Embeddable
@Searchable(root = false)
public class Who implements Serializable {

	private static final long serialVersionUID = 9095259401032266416L;

	private Long creationBy;
	private Date creationDate;
	private Long lastUpdateBy;
	private Date lastUpdateDate;
	
    /**
     * 返回创建人ID
     * @return long
     */
	@Column(name="CREATION_BY", precision=22)
	public Long getCreationBy() {
		return this.creationBy;
	}
	/**
	 * 设置创建人ID
	 * @param creationBy
	 */
	public void setCreationBy(Long creationBy) {
		this.creationBy = creationBy;
	}
	
	/**
	 * 返回创建时间
	 * @return Date
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="CREATION_DATE", columnDefinition="date")
	public Date getCreationDate() {
		return this.creationDate;
	}
	/**
	 * 设置创建时间，默认为当前时间
	 * @param creationDate
	 */	
	public void setCreationDate(Date creationDate) {
		this.creationDate = (creationDate==null ? new Date() : creationDate);
	}
	
	/**
	 * 返回最近修改人ID
	 * @return long
	 */
	@Column(name="LAST_UPDATE_BY", precision=22)
	public Long getLastUpdateBy() {
		return this.lastUpdateBy;
	}
	/**
	 * 设置最近修改人ID
	 * @param lastUpdateBy
	 */
	public void setLastUpdateBy(Long lastUpdateBy) {
		this.lastUpdateBy = lastUpdateBy;
	}

	/**
	 * 返回最近修改时间
	 * @return Date
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="LAST_UPDATE_DATE", columnDefinition="date")
	public Date getLastUpdateDate() {
		return this.lastUpdateDate;
	}
	/**
	 * 设置最近修改时间，默认为当前时间
	 * @param lastUpdateDate
	 */
	public void setLastUpdateDate(Date lastUpdateDate) {
		this.lastUpdateDate = (lastUpdateDate==null ? new Date() : lastUpdateDate);
	}
	
	@Override
	public String toString() {		
		return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
				.append("creationBy", this.creationBy)
				.append("creationDate", this.creationDate)
				.append("lastUpdateBy", this.lastUpdateBy)
				.append("lastUpdateDate", this.lastUpdateDate).toString();
	}
}
